/*
 * MembersSignIn.java
 *
 * Created on November 13, 2008, 8:59 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package jollylengkono.skripsi.Members.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jollylengkono.skripsi.Members.form.MembersSignInForm;
import jollylengkono.skripsi.dao.MembersDao;
import jollylengkono.skripsi.model.Members;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author JollkY
 */
public class MembersSignIn extends Action {
    private String FORWARD;
    private int STATE;
    
    /** Creates a new instance of MembersSignIn */
    public MembersSignIn() {
    }
    
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        MembersSignInForm memberForm = (MembersSignInForm) form;
        Members member = new Members();
        member.setUsername(memberForm.getUsername());
        member.setPassword(memberForm.getPassword());
        Members objMember = new MembersDao().signIn(member);
        HttpSession sess;
        if(objMember==null) {
            this.FORWARD="fail";
        } else {
            this.FORWARD="success";
            sess = request.getSession(true);
            sess.setAttribute("memberSessObject", objMember);
        }
        return mapping.findForward(FORWARD);
    }
    
}
